var /**
	 * 仿真流程管理
	 */
TeachFlow = cc.Class.extend({
	step:0,
	flow:null,
	main:null,
	over_flag: false,
	curSprite:null,
	ctor: function(){
		this.init();
	},
	setMain:function(main){
		this.main=main;
	},
	init: function(){
		for(var i in teach_flow){
			teach_flow[i].finish = false;
			teach_flow[i].cur = false;
			if(teach_flow[i].action == null){
				teach_flow[i].action = ACTION_NONE;
			}
		}
	},
	start:/**
			 * 开始流程
			 */
	function(){
		this.over_flag = false;
		this.step = 0;
		
		/* 新标准，开始的时候，执行下一步 */
		this.next();
	},
	over:/**
			 * 流程结束，计算分数，跳转到结束场景，
			 */
	function(){
		this.over_flag = true;
		this.flow = over;
		gg.lastStep = this.step;
		this.main.over();
	},
	checkTag:/**
				 * 检查是否当前步骤
				 * 
				 * @deprecated 使用新Angel类，不再判断是否当前步骤
				 * @param tag
				 * @returns {Boolean}
				 */
	function(tag){
		var cur_flow = teach_flow[this.step - 1];
		if(cur_flow.tag == tag){
			return true;
		} else {
			return false;
		}
	},
	prev:/**
			 * 回退一定步数
			 * 
			 * @deprecated 需结合具体实现，，暂时不再启动
			 * @param count
			 *            步数
			 */
	function(count){
		if(this.curSprite!=null){
			this.curSprite = null;
		}
		if(this.flow!=null){
			this.flow.cur = false;
		}
		this.step = this.step - count;
		this.flow = teach_flow[this.step - 1];
		this.refresh();
		gg.score -= 11;
	},
	next:/**
			 * 执行下一步操作， 定位当前任务
			 */
	function(){
		if(this.over_flag){
			return;
		}
		if(this.curSprite!=null){
			this.curSprite.setEnable(false)
			this.curSprite = null;
		}
		if(this.flow!=null){
			this.flow.cur = false;
			// 标记任务已完成
			this.flow.finish = true;
		}
		this.flow = teach_flow[this.step++];
		if(this.flow.finish){
			// 如果任务已完成，跳过当前步骤
			this.next();
		}
		this.refresh();
	},
	refresh:/**
			 * 刷新当前任务状态，设置闪现，点击等状态
			 */
	function(){
		// 刷新提示
		this.flow.cur = true;
		if(this.flow.tip != null){
			ll.tip.tip.doTip(this.flow.tip);
		}
		if(this.flow.flash != null){
			ll.tip.flash.doFlash(this.flow.flash);
		}
		if(this.step > teach_flow.length - 1){
			this.over();
		}
		this.initCurSprite();
		if(this.curSprite!=null){
			this.location();
			this.curSprite.setEnable(true);
		}
	},
	location:/**
				 * 定位箭头
				 */
	function(){
		ll.tip.arr.pos(this.curSprite);		
	},
	getStep:/**
			 * 获取当前步数
			 * 
			 * @returns {Number}
			 */
	function(){
		return this.step;
	},
	initCurSprite:/**
					 * 遍历获取当前任务的操作对象
					 */
	function(){
		var tag = this.flow.tag;
		if(tag == null || tag == undefined){
			return;
		}
		var root = ll.run;
		var sprite = null;
		if(tag == TAG_BUTTON_LIB){
			sprite = ll.tool.getChildByTag(tag);
		} else if(tag instanceof Array){
			// 数组
			for (var i in tag) {
				root = root.getChildByTag(tag[i]);
			}
			sprite = root;
		} else {
			// 单个tag
			var sprite = root.getChildByTag(tag);
		}
		if(sprite != null){
			this.curSprite = sprite;
			return;
		}
	}
});

// 任务流
teach_flow = [
// 取5g粗食盐
	{tip:"打开药品库",tag:TAG_BUTTON_LIB},
	{tip:"取出食盐",tag:[TAG_LIB,TAG_LIB_SALT]},
	{tip:"打开食盐样品瓶盖",tag:[TAG_SALT_BOTTLE,TAG_LID]},
	{tip:"用药匙，取5g粗食盐,放在天平右端",tag:[TAG_SALT_BOTTLE,TAG_SPOON]},
	{tip:"在药品库中取出一个烧杯1号",tag:[TAG_LIB,TAG_LIB_BEAKER],action:ACTION_DO1},
	{tip:"把粗盐放入烧杯1号",tag:TAG_PAPER},
	{tip:"在药品库中取出量筒",tag:[TAG_LIB,TAG_LIB_CYLINDER]},
	{tip:"在药品库中取出蒸馏水瓶",tag:[TAG_LIB,TAG_LIB_KETTLE]},
	{tip:"用量筒两区30ml蒸馏水",tag:TAG_KETTLE},
	{tip:"烧杯1号中加入30ml蒸馏水",tag:TAG_CYLINDER},
	{tip:"在药品库中取出玻璃棒",tag:[TAG_LIB,TAG_LIB_ROD],action:ACTION_DO1},
	{tip:"用玻璃棒搅拌,静置,等待溶解",tag:TAG_ROD,action:ACTION_DO1},
	
	{tip:"在药品库中取出铁架",tag:[TAG_LIB,TAG_LIB_IRON]},
	{tip:"在药品库中取出烧杯2号放在铁架上",tag:[TAG_LIB,TAG_LIB_BEAKER],action:ACTION_DO2},
	{tip:"在药品库中取出漏斗,滤纸紧贴漏斗",tag:[TAG_LIB,TAG_LIB_FUNNEL]},
	{tip:"在药品库中取出滤纸,",tag:[TAG_LIB,TAG_LIB_PAPER]},
	{tip:"按照提示,折叠成圆锥状",tag:[TAG_WIN_NODE,TAG_WIN_CLOSE],action:ACTION_DO1},
	{tip:"在药品库中取出玻璃棒",tag:[TAG_LIB,TAG_LIB_ROD],action:ACTION_DO2},
	{tip:"用玻璃棒靠三层滤纸",tag:TAG_ROD,action:ACTION_DO2},
	{tip:"按照提示,放置玻璃棒",tag:[TAG_WIN_NODE,TAG_WIN_CLOSE],action:ACTION_DO2},
	{tip:"把烧杯1号中的粗盐溶液通过玻璃棒过滤，弃去沉淀",tag:TAG_BEAKER},
	{tip:"在药品库中取出三脚架",tag:[TAG_LIB,TAG_LIB_SHELF]},
	{tip:"在药品库中取出石棉网，放置三脚架上",tag:[TAG_LIB,TAG_LIB_NET]},
	
	{tip:"把烧杯2号放在石棉网上",tag:TAG_BEAKER2,action:ACTION_DO1},
	{tip:"在药品库中取出1mol/L的BaCl2溶液",tag:[TAG_LIB,TAG_LIB_DROP],action:ACTION_DO1},
	{tip:"滤液添加BaCl2 1ml",tag:[TAG_BACL,TAG_DROP],action:ACTION_DO1},
	{tip:"在药品库中取出酒精灯",tag:[TAG_LIB,TAG_LIB_LAMP]},
	{tip:"打开酒精灯帽",tag:[TAG_LAMP,TAG_LAMP_LID],action:ACTION_DO1},
	{tip:"把酒精灯放入三脚架",tag:[TAG_LAMP, TAG_LAMP],action:ACTION_DO1},
	{tip:"在药品库中取出火柴盒",tag:[TAG_LIB,TAG_LIB_MATCH]},
	{tip:"从火柴盒中取出火柴",tag:[TAG_MATCH_NODE,TAG_MATCH_BOX]},
	{tip:"点燃火柴",tag:[TAG_MATCH_NODE,TAG_MATCH],action:ACTION_DO1},
	{tip:"用火柴点燃酒精灯",tag:[TAG_MATCH_NODE,TAG_MATCH],action:ACTION_DO2},
	{tip:"加热2-3分钟，沉淀完全"},
	{tip:"在药品库中再取出一个烧杯3号放在铁架上",tag:[TAG_LIB,TAG_LIB_BEAKER],action:ACTION_DO3},
	{tip:"把烧杯2号中的溶液通过玻璃棒过滤，弃去沉淀",tag:TAG_BEAKER2,action:ACTION_DO2},
	{tip:"把烧杯3号放在石棉网上",tag:TAG_BEAKER3,action:ACTION_DO1},
	{tip:"在药品库中取出2mol/L的NaOH溶液",tag:[TAG_LIB,TAG_LIB_DROP],action:ACTION_DO2},
	{tip:"滤液添加NaOH 1ml",tag:[TAG_NAOH,TAG_DROP],action:ACTION_DO2},
	{tip:"在药品库中取出2mol/L的Na2CO3溶液",tag:[TAG_LIB,TAG_LIB_DROP],action:ACTION_DO3},
	{tip:"滤液添加Na2CO3 1ml,沉淀完全",tag:[TAG_NA2CO3,TAG_DROP],action:ACTION_DO3},
	
	{tip:"在药品库中再取出一个烧杯4号放在铁架上",tag:[TAG_LIB,TAG_LIB_BEAKER],action:ACTION_NONE},
	{tip:"把烧杯3号中的溶液通过玻璃棒过滤，弃去沉淀",tag:TAG_BEAKER3,action:ACTION_DO2},
	
	{tip:"把烧杯4号拿出来",tag:TAG_BEAKER4,action:ACTION_DO1},
	
	{tip:"在药品库中取出6mol/L的HCL溶液",tag:[TAG_LIB,TAG_LIB_DROP],action:ACTION_DO4},
	{tip:"滤液中添加HCL,",tag:[TAG_HCL,TAG_DROP],action:ACTION_DO2},
	
	{tip:"在药品库中取出pH试纸和比色卡",tag:[TAG_LIB,TAG_LIB_PH]},
	{tip:"用玻璃棒蘸取一滴溶液放到pH试纸上",tag:TAG_ROD,action:ACTION_DO5},
	{tip:"对比比色卡颜色,颜色在pH4到5之间",tag:[TAG_PH_NODE,TAG_PH],action:ACTION_DO1},
	
	{tip:"在药品库中取出一个坩埚在铁架上",tag:[TAG_LIB,TAG_LIB_POT]},
	{tip:"把烧杯4号的溶液放在坩埚里",tag:TAG_BEAKER4,action:ACTION_DO2},
	{tip:"在药品库中取出玻璃棒",tag:[TAG_LIB,TAG_LIB_ROD],action:ACTION_DO1},
	{tip:"用玻璃棒搅拌,蒸发、浓缩",tag:TAG_ROD,action:ACTION_DO3},
	{tip:"水分快要蒸干时，撤去酒精灯",tag:[TAG_LAMP, TAG_LAMP],action:ACTION_DO2},
	{tip:"用酒精灯帽熄灭酒精灯",tag:[TAG_LAMP,TAG_LAMP_LID],action:ACTION_DO2},
	{tip:"等待冷却至室温"},
	{tip:"在药品库中取出气压机,",tag:[TAG_LIB,TAG_LIB_AIR]},
	{tip:"在药品库中取出药匙,",tag:[TAG_LIB,TAG_LIB_SPOON]},
	{tip:"用药匙把蒸发皿中的食盐刮到布氏漏斗里",tag:[TAG_POT_NODE, TAG_POT]},
	{tip:"找到气压机开关按钮",tag:TAG_AIR},
	{tip:"按下开关,启动气压机,生成固体NaCl",tag:[TAG_AIR_SIDE_NODE, TAG_AIR_SIDE_BT]},
	
	{tip:"在药品库中取出酒精",tag:[TAG_LIB,TAG_LIB_DROP],action:ACTION_NONE},
	{tip:"用酒精洗涤固体NaCl",tag:[TAG_ALCOHOL,TAG_DROP],action:ACTION_DO2},
	
	{tip:"在药品库中取出滤纸",tag:[TAG_LIB,TAG_LIB_PAPER2]},
	{tip:"生成NaCl晶体，用药匙，把NaCl晶体刮到滤纸上",tag:[TAG_AIR, TAG_AIR_FUNNEL]},
	{tip:"把滤纸移到天平左端,称重",tag:TAG_PAPER2,action:ACTION_DO1},
	{tip:"提纯后精盐不足5g,移除砝码,拨动游码",tag:[TAG_BALANCE,TAG_FAMA]},
	{tip:"在药品库中取出装精盐的广口瓶",tag:[TAG_LIB,TAG_LIB_WIDE]},
	{tip:"打开广口瓶的盖子",tag:[TAG_WIDE_NODE,TAG_WDIE_LID],action:ACTION_DO1},
	{tip:"把滤纸中的精盐装入广口瓶",tag:TAG_PAPER2,action:ACTION_DO2},
	{tip:"盖上广口瓶的盖子",tag:[TAG_WIDE_NODE,TAG_WDIE_LID],action:ACTION_DO2},
	{tip:"恭喜过关",over:true}
];
over = {tip:"恭喜过关"};



